package common;


import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class GetLines {

	private static String GET_ALL_LINES_URL = "http://106.15.43.138:8080/api/line/all_lines";
	
	public static String getLines(String lineId){
		JSONObject json = new JSONObject();
		json.put("version", "0");
		String aJson = PostJson.postJson(json, GET_ALL_LINES_URL);
		JSONObject bJson = JSONObject.fromObject(aJson);
		JSONArray result = bJson.getJSONArray("result");
		for(int i = 0;i<result.size();i++){
			JSONObject message = result.getJSONObject(i);
			if (lineId.equals(message.getString("line_id"))) {
				return message.getString("line_name");
			}
		}
		return null;
	}
}
